cmake_minimum_required(VERSION 3.9)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

macro(create_isa_lib isa)
    file(GLOB LIB_SOURCES  ${isa}/*.cpp)
    file(GLOB LIB_HEADERS ripesprocessor.h ${isa}/*.h)
    add_library(${isa}_lib ${LIB_SOURCES} ${LIB_HEADERS})
endmacro()

macro(create_processor isa name)
    file(GLOB LIB_SOURCES  ${isa}/${name}/*.cpp)
    file(GLOB LIB_HEADERS ripesprocessor.h ${isa}/${name}/*.h)
    add_library(${name} ${LIB_SOURCES} ${LIB_HEADERS})
    target_link_libraries(${name} ${VSRTL_CORE_LIB} ${isa}_lib)
    target_include_directories(${name} PUBLIC ${isa}/*.h)
    target_include_directories(${name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
    target_include_directories(${name} PUBLIC ${CMAKE_SOURCE_DIR}/external)
    target_compile_features(${name} PRIVATE cxx_std_17)
endmacro()

# RISC-V Processors
create_isa_lib(RISC-V)
create_processor(RISC-V rvss)
create_processor(RISC-V rv5s)
create_processor(RISC-V rv5s_no_fw_hz)
create_processor(RISC-V rv5s_no_hz)
